/*++

Copyright (c) 2007  Microsoft Corporation 

Filename: 

    FrmSelectColumns.cs

Abstract: 

    Form to select columns for data from Excel Worksheets
     
--*/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using AddIn.Windows.Forms;
using UtilityManager;
using Visio = Microsoft.Office.Interop.Visio;
using System.Reflection;

namespace RackServerManager
{
    public partial class FrmSelectColumns : AddIn.Windows.Forms.InteriorWizardPage
    {
        #region Form Variables
        private System.Windows.Forms.TabControl tbCtrlSheetColumns;
        private System.Windows.Forms.TabPage tbPageServer;
        private System.Windows.Forms.TabPage tbPageRack;
        private System.Windows.Forms.TabPage tbPageColo;
        private System.Windows.Forms.Label titleLabel;
        private System.Windows.Forms.GroupBox gbColoPage;
        private System.Windows.Forms.ComboBox cmbColoMaxUnits;
        private System.Windows.Forms.ComboBox cmbColoName3;
        private System.Windows.Forms.Label lblExcelColumns3;
        private System.Windows.Forms.Label lblColoMaxUnits;
        private System.Windows.Forms.Label lblColoName3;
        private System.Windows.Forms.Label lblShapeField3;
        private System.Windows.Forms.GroupBox gbServerPage;
        private System.Windows.Forms.GroupBox gbRackPage;
        private System.Windows.Forms.ComboBox cmbColoName2;
        private System.Windows.Forms.ComboBox cmbMaxUnits;
        private System.Windows.Forms.ComboBox cmbPowerRating2;
        private System.Windows.Forms.ComboBox cmbRackName2;
        private System.Windows.Forms.Label lblExcelColumns2;
        private System.Windows.Forms.Label lblColoName2;
        private System.Windows.Forms.Label lblMaxUnits;
        private System.Windows.Forms.Label lblPowerRating2;
        private System.Windows.Forms.Label lblRackName2;
        private System.Windows.Forms.Label lblShapeField2;
        private System.Windows.Forms.ComboBox cmbColoName1;
        private System.Windows.Forms.ComboBox cmbRackName1;
        private System.Windows.Forms.ComboBox cmbSpaceUsed;
        private System.Windows.Forms.ComboBox cmbPowerRating1;
        private System.Windows.Forms.ComboBox cmbNetworkName;
        private System.Windows.Forms.Label lblExcelColumns1;
        private System.Windows.Forms.Label lblColoName1;
        private System.Windows.Forms.Label lblRackName1;
        private System.Windows.Forms.Label lblSpaceUsed;
        private System.Windows.Forms.Label lblPowerRating1;
        private System.Windows.Forms.Label lblNetworkName;
        private System.Windows.Forms.Label lblShapeField1;        
        #endregion

        #region Constructor
        /// <summary>
        /// Default Constructor
        /// </summary>
        public FrmSelectColumns()
        {
            InitializeComponent();
            this.titleLabel.Text = Global.GetResourceString("FormSelectColumnsTitle_Text");

            this.tbPageServer.Text = Global.GetResourceString("ServerTab3_Text");
            this.tbPageRack.Text = Global.GetResourceString("RackTab2_Text");
            this.tbPageColo.Text = Global.GetResourceString("ColoTab1_Text");

            this.lblShapeField1.Text = Global.GetResourceString("FormSelectColumnsShapeTitle_Text");
            this.lblNetworkName.Text = Global.GetResourceString("FormSelectColumnsServerShapeField1_Text");
            this.lblPowerRating1.Text = Global.GetResourceString("FormSelectColumnsServerShapeField2_Text");
            this.lblSpaceUsed.Text = Global.GetResourceString("FormSelectColumnsServerShapeField3_Text");
            this.lblRackName1.Text = Global.GetResourceString("FormSelectColumnsServerShapeField4_Text");
            this.lblColoName1.Text = Global.GetResourceString("FormSelectColumnsServerShapeField5_Text");
            this.lblExcelColumns1.Text = Global.GetResourceString("FormSelectColumnsExcelTitle_Text");

            this.lblShapeField2.Text = Global.GetResourceString("FormSelectColumnsShapeTitle_Text");
            this.lblRackName2.Text = Global.GetResourceString("FormSelectColumnsRackShapeField1_Text");
            this.lblPowerRating2.Text = Global.GetResourceString("FormSelectColumnsRackShapeField2_Text");
            this.lblMaxUnits.Text = Global.GetResourceString("FormSelectColumnsRackShapeField3_Text");
            this.lblColoName2.Text = Global.GetResourceString("FormSelectColumnsRackShapeField4_Text");
            this.lblExcelColumns2.Text = Global.GetResourceString("FormSelectColumnsExcelTitle_Text");

            this.lblShapeField3.Text = Global.GetResourceString("FormSelectColumnsShapeTitle_Text");
            this.lblColoName3.Text = Global.GetResourceString("FormSelectColumnsColoShapeField1_Text");
            this.lblColoMaxUnits.Text = Global.GetResourceString("FormSelectColumnsColoShapeField2_Text");
            this.lblExcelColumns3.Text = Global.GetResourceString("FormSelectColumnsExcelTitle_Text");

            this.HeaderPanel.Controls.Add(this.titleLabel);
            this.HeaderPanel.ResumeLayout(false);
        }
        #endregion Constructor

        #region Wizard Methods
        /// <summary>
        /// On Form Active
        /// </summary>
        /// <returns></returns>
        protected override bool OnSetActive()
        {
            if (!base.OnSetActive())
                return false;

            // Enable both the Back and Finish (enabled/disabled) buttons on this page    
            Wizard.SetWizardButtons(WizardButtons.Back | WizardButtons.Finish);

            try
            {
                // Load column names of different sheets into cmboboxes
                this.LoadServerColumnNames();
                this.LoadRackColumnNames();
                this.LoadColoColumnNames();
            }
            catch (RackException ex)
            {

                // To catch and display exceptions from sub functions
                RackException.HandleExceptions(Global.GetResourceString("Exception_MsgBox_Caption"),
                            Global.GetResourceString("Exception_UsrMsg"), ex.InnerException);

                return false;
            }
            catch (Exception ex)
            {
                // To catch exceptions from current functions
                RackException.HandleExceptions(Global.GetResourceString("Exception_MsgBox_Caption"),
                            Global.GetResourceString("Exception_UsrMsg"), ex);

                return false;
            }

            return true;
        }       

        /// <summary>
        /// On Back clicked
        /// </summary>
        /// <returns></returns>
        protected override string OnWizardBack()
        {   
            // Form Select Worksheet
            return "FrmSelectWorksheet";         
        }

        /// <summary>
        /// On Finish clicked
        /// </summary>
        /// <returns></returns>
        protected override bool OnWizardFinish()
        {
            try
            {
                // Check default selected text as column name if true popup a message
                if (
                    (String.Compare(cmbNetworkName.SelectedItem.ToString(), Global.GetResourceString("FormSelectDefaultCombo_Text")) != 0) &&
                    (String.Compare(cmbPowerRating1.SelectedItem.ToString(), Global.GetResourceString("FormSelectDefaultCombo_Text")) != 0) &&
                    (String.Compare(cmbSpaceUsed.SelectedItem.ToString(), Global.GetResourceString("FormSelectDefaultCombo_Text")) != 0) &&
                    (String.Compare(cmbRackName1.SelectedItem.ToString(), Global.GetResourceString("FormSelectDefaultCombo_Text")) != 0) &&
                    (String.Compare(cmbColoName1.SelectedItem.ToString(), Global.GetResourceString("FormSelectDefaultCombo_Text")) != 0) &&
                    (String.Compare(cmbRackName2.SelectedItem.ToString(), Global.GetResourceString("FormSelectDefaultCombo_Text")) != 0) &&
                    (String.Compare(cmbPowerRating2.SelectedItem.ToString(), Global.GetResourceString("FormSelectDefaultCombo_Text")) != 0) &&
                    (String.Compare(cmbMaxUnits.SelectedItem.ToString(), Global.GetResourceString("FormSelectDefaultCombo_Text")) != 0) &&
                    (String.Compare(cmbColoName2.SelectedItem.ToString(), Global.GetResourceString("FormSelectDefaultCombo_Text")) != 0) &&
                    (String.Compare(cmbColoName3.SelectedItem.ToString(), Global.GetResourceString("FormSelectDefaultCombo_Text")) != 0) &&
                    (String.Compare(cmbColoMaxUnits.SelectedItem.ToString(), Global.GetResourceString("FormSelectDefaultCombo_Text")) != 0)
                   )
                {
                  
                    // Sql Commands to retrieve data from excel                   
                    Global.ColoSelectQuery = @"SELECT [" + cmbColoName3.SelectedItem + "]" +
                            " as [" + Global.ColoFieldColoName + "], [" + cmbColoMaxUnits.SelectedItem + "]" +
                            " as [" + Global.ColoFieldMaxUnits + "] FROM [" + Global.SheetColoSelect + "]";

                    Global.RackSelectQuery = @"SELECT [" + cmbRackName2.SelectedItem + "]" +
                        " as [" + Global.RackFieldRackName + "], [" + cmbPowerRating2.SelectedItem + "]" +
                        " as [" + Global.RackFieldPowerRating + "], [" + cmbMaxUnits.SelectedItem + "]" +
                        " as [" + Global.RackFieldMaxUnits + "], [" + cmbColoName2.SelectedItem + "]" +
                        " as [" + Global.RackFieldColoName + "]  FROM [" + Global.SheetRackSelect + "]";

                    Global.ServerSelectQuery = @"SELECT [" + cmbNetworkName.SelectedItem + "]" +
                        " as [" + Global.ServerFieldNetworkName + "], [" + cmbPowerRating1.SelectedItem + "]" +
                        " as [" + Global.ServerFieldPowerRating + "], [" + cmbSpaceUsed.SelectedItem + "]" +
                        " as [" + Global.ServerFieldRackSpace + "], [" + cmbRackName1.SelectedItem + "]" +
                        " as [" + Global.ServerFieldRackName + "], [" + cmbColoName1.SelectedItem + "]" +
                        " as [" + Global.ServerFieldColoName + "]," +
                        " '' as [" + Global.ServerFieldIPAdress + "], '' as [" + Global.ServerFieldOperatingSystem + "]," + 
                        " '' as [" + Global.ServerFieldProcessor + "], '' as [" + Global.ServerFieldCpuUsage + "], " +
                        " '' as [" + Global.ServerFieldTotalMem + "], '' as [" + Global.ServerFieldAvailMem + "]," +
                        " '' as [" + Global.ServerFieldIsVirtual + "]" +
                        " FROM [" + Global.SheetServerSelect + "]";
                    
                    // Flag set to create datarecordset
                    Global.RecordSetCreated = true;

                }
                else
                {
                    MessageBox.Show(Global.GetResourceString("ColumnSelection_Text"),
                            Global.GetResourceString("VirtualRack_MsgBox_Title"),
                            MessageBoxButtons.OK, MessageBoxIcon.Warning,
                            MessageBoxDefaultButton.Button1);
                    
                    return false;
                }
            }
            catch (RackException ex)
            {

                // To catch and display exceptions from sub functions
                RackException.HandleExceptions(Global.GetResourceString("Exception_MsgBox_Caption"),
                            Global.GetResourceString("Exception_UsrMsg"), ex.InnerException);

                return false;
            }
            catch (Exception ex)
            {
                // To catch exceptions from current functions
                RackException.HandleExceptions(Global.GetResourceString("Exception_MsgBox_Caption"),
                            Global.GetResourceString("Exception_UsrMsg"), ex);

                return false;
            }
            return true;
        }
        #endregion Wizard Methods

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.tbCtrlSheetColumns = new System.Windows.Forms.TabControl();
            this.tbPageServer = new System.Windows.Forms.TabPage();
            this.gbServerPage = new System.Windows.Forms.GroupBox();
            this.cmbColoName1 = new System.Windows.Forms.ComboBox();
            this.cmbRackName1 = new System.Windows.Forms.ComboBox();
            this.cmbSpaceUsed = new System.Windows.Forms.ComboBox();
            this.cmbPowerRating1 = new System.Windows.Forms.ComboBox();
            this.cmbNetworkName = new System.Windows.Forms.ComboBox();
            this.lblExcelColumns1 = new System.Windows.Forms.Label();
            this.lblColoName1 = new System.Windows.Forms.Label();
            this.lblRackName1 = new System.Windows.Forms.Label();
            this.lblSpaceUsed = new System.Windows.Forms.Label();
            this.lblPowerRating1 = new System.Windows.Forms.Label();
            this.lblNetworkName = new System.Windows.Forms.Label();
            this.lblShapeField1 = new System.Windows.Forms.Label();
            this.tbPageRack = new System.Windows.Forms.TabPage();
            this.gbRackPage = new System.Windows.Forms.GroupBox();
            this.cmbColoName2 = new System.Windows.Forms.ComboBox();
            this.cmbMaxUnits = new System.Windows.Forms.ComboBox();
            this.cmbPowerRating2 = new System.Windows.Forms.ComboBox();
            this.cmbRackName2 = new System.Windows.Forms.ComboBox();
            this.lblExcelColumns2 = new System.Windows.Forms.Label();
            this.lblColoName2 = new System.Windows.Forms.Label();
            this.lblMaxUnits = new System.Windows.Forms.Label();
            this.lblPowerRating2 = new System.Windows.Forms.Label();
            this.lblRackName2 = new System.Windows.Forms.Label();
            this.lblShapeField2 = new System.Windows.Forms.Label();
            this.tbPageColo = new System.Windows.Forms.TabPage();
            this.gbColoPage = new System.Windows.Forms.GroupBox();
            this.cmbColoMaxUnits = new System.Windows.Forms.ComboBox();
            this.cmbColoName3 = new System.Windows.Forms.ComboBox();
            this.lblExcelColumns3 = new System.Windows.Forms.Label();
            this.lblColoMaxUnits = new System.Windows.Forms.Label();
            this.lblColoName3 = new System.Windows.Forms.Label();
            this.lblShapeField3 = new System.Windows.Forms.Label();
            this.titleLabel = new System.Windows.Forms.Label();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBoxIcon)).BeginInit();
            this.tbCtrlSheetColumns.SuspendLayout();
            this.tbPageServer.SuspendLayout();
            this.gbServerPage.SuspendLayout();
            this.tbPageRack.SuspendLayout();
            this.gbRackPage.SuspendLayout();
            this.tbPageColo.SuspendLayout();
            this.gbColoPage.SuspendLayout();
            this.SuspendLayout();
            // 
            // tbCtrlSheetColumns
            // 
            this.tbCtrlSheetColumns.Controls.Add(this.tbPageServer);
            this.tbCtrlSheetColumns.Controls.Add(this.tbPageRack);
            this.tbCtrlSheetColumns.Controls.Add(this.tbPageColo);
            this.tbCtrlSheetColumns.Location = new System.Drawing.Point(15, 71);
            this.tbCtrlSheetColumns.Name = "tbCtrlSheetColumns";
            this.tbCtrlSheetColumns.SelectedIndex = 0;
            this.tbCtrlSheetColumns.Size = new System.Drawing.Size(466, 228);
            this.tbCtrlSheetColumns.TabIndex = 1;
            // 
            // tbPageServer
            // 
            this.tbPageServer.Controls.Add(this.gbServerPage);
            this.tbPageServer.Location = new System.Drawing.Point(4, 22);
            this.tbPageServer.Name = "tbPageServer";
            this.tbPageServer.Padding = new System.Windows.Forms.Padding(3);
            this.tbPageServer.Size = new System.Drawing.Size(458, 202);
            this.tbPageServer.TabIndex = 0;
            this.tbPageServer.UseVisualStyleBackColor = true;
            // 
            // gbServerPage
            // 
            this.gbServerPage.Controls.Add(this.cmbColoName1);
            this.gbServerPage.Controls.Add(this.cmbRackName1);
            this.gbServerPage.Controls.Add(this.cmbSpaceUsed);
            this.gbServerPage.Controls.Add(this.cmbPowerRating1);
            this.gbServerPage.Controls.Add(this.cmbNetworkName);
            this.gbServerPage.Controls.Add(this.lblExcelColumns1);
            this.gbServerPage.Controls.Add(this.lblColoName1);
            this.gbServerPage.Controls.Add(this.lblRackName1);
            this.gbServerPage.Controls.Add(this.lblSpaceUsed);
            this.gbServerPage.Controls.Add(this.lblPowerRating1);
            this.gbServerPage.Controls.Add(this.lblNetworkName);
            this.gbServerPage.Controls.Add(this.lblShapeField1);
            this.gbServerPage.Location = new System.Drawing.Point(6, 7);
            this.gbServerPage.Name = "gbServerPage";
            this.gbServerPage.Size = new System.Drawing.Size(446, 189);
            this.gbServerPage.TabIndex = 12;
            this.gbServerPage.TabStop = false;
            // 
            // cmbColoName1
            // 
            this.cmbColoName1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.cmbColoName1.FormattingEnabled = true;
            this.cmbColoName1.Location = new System.Drawing.Point(138, 162);
            this.cmbColoName1.Name = "cmbColoName1";
            this.cmbColoName1.Size = new System.Drawing.Size(279, 21);
            this.cmbColoName1.TabIndex = 22;
            // 
            // cmbRackName1
            // 
            this.cmbRackName1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.cmbRackName1.FormattingEnabled = true;
            this.cmbRackName1.Location = new System.Drawing.Point(138, 132);
            this.cmbRackName1.Name = "cmbRackName1";
            this.cmbRackName1.Size = new System.Drawing.Size(279, 21);
            this.cmbRackName1.TabIndex = 20;
            // 
            // cmbSpaceUsed
            // 
            this.cmbSpaceUsed.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.cmbSpaceUsed.FormattingEnabled = true;
            this.cmbSpaceUsed.Location = new System.Drawing.Point(138, 104);
            this.cmbSpaceUsed.Name = "cmbSpaceUsed";
            this.cmbSpaceUsed.Size = new System.Drawing.Size(279, 21);
            this.cmbSpaceUsed.TabIndex = 18;
            // 
            // cmbPowerRating1
            // 
            this.cmbPowerRating1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.cmbPowerRating1.FormattingEnabled = true;
            this.cmbPowerRating1.Location = new System.Drawing.Point(138, 75);
            this.cmbPowerRating1.Name = "cmbPowerRating1";
            this.cmbPowerRating1.Size = new System.Drawing.Size(279, 21);
            this.cmbPowerRating1.TabIndex = 16;
            // 
            // cmbNetworkName
            // 
            this.cmbNetworkName.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.cmbNetworkName.FormattingEnabled = true;
            this.cmbNetworkName.Location = new System.Drawing.Point(138, 48);
            this.cmbNetworkName.Name = "cmbNetworkName";
            this.cmbNetworkName.Size = new System.Drawing.Size(279, 21);
            this.cmbNetworkName.TabIndex = 14;
            // 
            // lblExcelColumns1
            // 
            this.lblExcelColumns1.AutoSize = true;
            this.lblExcelColumns1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.lblExcelColumns1.Location = new System.Drawing.Point(215, 16);
            this.lblExcelColumns1.Name = "lblExcelColumns1";
            this.lblExcelColumns1.Size = new System.Drawing.Size(0, 13);
            this.lblExcelColumns1.TabIndex = 23;
            // 
            // lblColoName1
            // 
            this.lblColoName1.AutoSize = true;
            this.lblColoName1.Location = new System.Drawing.Point(41, 162);
            this.lblColoName1.Name = "lblColoName1";
            this.lblColoName1.Size = new System.Drawing.Size(0, 13);
            this.lblColoName1.TabIndex = 21;
            // 
            // lblRackName1
            // 
            this.lblRackName1.AutoSize = true;
            this.lblRackName1.Location = new System.Drawing.Point(41, 132);
            this.lblRackName1.Name = "lblRackName1";
            this.lblRackName1.Size = new System.Drawing.Size(0, 13);
            this.lblRackName1.TabIndex = 19;
            // 
            // lblSpaceUsed
            // 
            this.lblSpaceUsed.AutoSize = true;
            this.lblSpaceUsed.Location = new System.Drawing.Point(41, 104);
            this.lblSpaceUsed.Name = "lblSpaceUsed";
            this.lblSpaceUsed.Size = new System.Drawing.Size(0, 13);
            this.lblSpaceUsed.TabIndex = 17;
            // 
            // lblPowerRating1
            // 
            this.lblPowerRating1.AutoSize = true;
            this.lblPowerRating1.Location = new System.Drawing.Point(41, 75);
            this.lblPowerRating1.Name = "lblPowerRating1";
            this.lblPowerRating1.Size = new System.Drawing.Size(0, 13);
            this.lblPowerRating1.TabIndex = 15;
            // 
            // lblNetworkName
            // 
            this.lblNetworkName.AutoSize = true;
            this.lblNetworkName.Location = new System.Drawing.Point(41, 48);
            this.lblNetworkName.Name = "lblNetworkName";
            this.lblNetworkName.Size = new System.Drawing.Size(0, 13);
            this.lblNetworkName.TabIndex = 13;
            // 
            // lblShapeField1
            // 
            this.lblShapeField1.AutoSize = true;
            this.lblShapeField1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.lblShapeField1.ForeColor = System.Drawing.SystemColors.ControlText;
            this.lblShapeField1.Location = new System.Drawing.Point(41, 16);
            this.lblShapeField1.Name = "lblShapeField1";
            this.lblShapeField1.Size = new System.Drawing.Size(0, 13);
            this.lblShapeField1.TabIndex = 12;
            // 
            // tbPageRack
            // 
            this.tbPageRack.Controls.Add(this.gbRackPage);
            this.tbPageRack.Location = new System.Drawing.Point(4, 22);
            this.tbPageRack.Name = "tbPageRack";
            this.tbPageRack.Padding = new System.Windows.Forms.Padding(3);
            this.tbPageRack.Size = new System.Drawing.Size(458, 202);
            this.tbPageRack.TabIndex = 1;
            this.tbPageRack.UseVisualStyleBackColor = true;
            // 
            // gbRackPage
            // 
            this.gbRackPage.Controls.Add(this.cmbColoName2);
            this.gbRackPage.Controls.Add(this.cmbMaxUnits);
            this.gbRackPage.Controls.Add(this.cmbPowerRating2);
            this.gbRackPage.Controls.Add(this.cmbRackName2);
            this.gbRackPage.Controls.Add(this.lblExcelColumns2);
            this.gbRackPage.Controls.Add(this.lblColoName2);
            this.gbRackPage.Controls.Add(this.lblMaxUnits);
            this.gbRackPage.Controls.Add(this.lblPowerRating2);
            this.gbRackPage.Controls.Add(this.lblRackName2);
            this.gbRackPage.Controls.Add(this.lblShapeField2);
            this.gbRackPage.Location = new System.Drawing.Point(6, 6);
            this.gbRackPage.Name = "gbRackPage";
            this.gbRackPage.Size = new System.Drawing.Size(446, 189);
            this.gbRackPage.TabIndex = 10;
            this.gbRackPage.TabStop = false;
            // 
            // cmbColoName2
            // 
            this.cmbColoName2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.cmbColoName2.FormattingEnabled = true;
            this.cmbColoName2.Location = new System.Drawing.Point(138, 155);
            this.cmbColoName2.Name = "cmbColoName2";
            this.cmbColoName2.Size = new System.Drawing.Size(279, 21);
            this.cmbColoName2.TabIndex = 18;
            // 
            // cmbMaxUnits
            // 
            this.cmbMaxUnits.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.cmbMaxUnits.FormattingEnabled = true;
            this.cmbMaxUnits.Location = new System.Drawing.Point(138, 120);
            this.cmbMaxUnits.Name = "cmbMaxUnits";
            this.cmbMaxUnits.Size = new System.Drawing.Size(279, 21);
            this.cmbMaxUnits.TabIndex = 16;
            // 
            // cmbPowerRating2
            // 
            this.cmbPowerRating2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.cmbPowerRating2.FormattingEnabled = true;
            this.cmbPowerRating2.Location = new System.Drawing.Point(138, 84);
            this.cmbPowerRating2.Name = "cmbPowerRating2";
            this.cmbPowerRating2.Size = new System.Drawing.Size(279, 21);
            this.cmbPowerRating2.TabIndex = 14;
            // 
            // cmbRackName2
            // 
            this.cmbRackName2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.cmbRackName2.FormattingEnabled = true;
            this.cmbRackName2.Location = new System.Drawing.Point(138, 47);
            this.cmbRackName2.Name = "cmbRackName2";
            this.cmbRackName2.Size = new System.Drawing.Size(279, 21);
            this.cmbRackName2.TabIndex = 12;
            // 
            // lblExcelColumns2
            // 
            this.lblExcelColumns2.AutoSize = true;
            this.lblExcelColumns2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.lblExcelColumns2.Location = new System.Drawing.Point(215, 16);
            this.lblExcelColumns2.Name = "lblExcelColumns2";
            this.lblExcelColumns2.Size = new System.Drawing.Size(0, 13);
            this.lblExcelColumns2.TabIndex = 19;
            // 
            // lblColoName2
            // 
            this.lblColoName2.AutoSize = true;
            this.lblColoName2.Location = new System.Drawing.Point(40, 155);
            this.lblColoName2.Name = "lblColoName2";
            this.lblColoName2.Size = new System.Drawing.Size(0, 13);
            this.lblColoName2.TabIndex = 17;
            // 
            // lblMaxUnits
            // 
            this.lblMaxUnits.AutoSize = true;
            this.lblMaxUnits.Location = new System.Drawing.Point(40, 119);
            this.lblMaxUnits.Name = "lblMaxUnits";
            this.lblMaxUnits.Size = new System.Drawing.Size(0, 13);
            this.lblMaxUnits.TabIndex = 15;
            // 
            // lblPowerRating2
            // 
            this.lblPowerRating2.AutoSize = true;
            this.lblPowerRating2.Location = new System.Drawing.Point(40, 84);
            this.lblPowerRating2.Name = "lblPowerRating2";
            this.lblPowerRating2.Size = new System.Drawing.Size(0, 13);
            this.lblPowerRating2.TabIndex = 13;
            // 
            // lblRackName2
            // 
            this.lblRackName2.AutoSize = true;
            this.lblRackName2.Location = new System.Drawing.Point(40, 47);
            this.lblRackName2.Name = "lblRackName2";
            this.lblRackName2.Size = new System.Drawing.Size(0, 13);
            this.lblRackName2.TabIndex = 11;
            // 
            // lblShapeField2
            // 
            this.lblShapeField2.AutoSize = true;
            this.lblShapeField2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.lblShapeField2.Location = new System.Drawing.Point(40, 16);
            this.lblShapeField2.Name = "lblShapeField2";
            this.lblShapeField2.Size = new System.Drawing.Size(0, 13);
            this.lblShapeField2.TabIndex = 10;
            // 
            // tbPageColo
            // 
            this.tbPageColo.Controls.Add(this.gbColoPage);
            this.tbPageColo.Location = new System.Drawing.Point(4, 22);
            this.tbPageColo.Name = "tbPageColo";
            this.tbPageColo.Padding = new System.Windows.Forms.Padding(3);
            this.tbPageColo.Size = new System.Drawing.Size(458, 202);
            this.tbPageColo.TabIndex = 2;
            this.tbPageColo.UseVisualStyleBackColor = true;
            // 
            // gbColoPage
            // 
            this.gbColoPage.Controls.Add(this.cmbColoMaxUnits);
            this.gbColoPage.Controls.Add(this.cmbColoName3);
            this.gbColoPage.Controls.Add(this.lblExcelColumns3);
            this.gbColoPage.Controls.Add(this.lblColoMaxUnits);
            this.gbColoPage.Controls.Add(this.lblColoName3);
            this.gbColoPage.Controls.Add(this.lblShapeField3);
            this.gbColoPage.Location = new System.Drawing.Point(6, 7);
            this.gbColoPage.Name = "gbColoPage";
            this.gbColoPage.Size = new System.Drawing.Size(446, 189);
            this.gbColoPage.TabIndex = 6;
            this.gbColoPage.TabStop = false;
            // 
            // cmbColoMaxUnits
            // 
            this.cmbColoMaxUnits.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.cmbColoMaxUnits.FormattingEnabled = true;
            this.cmbColoMaxUnits.Location = new System.Drawing.Point(138, 114);
            this.cmbColoMaxUnits.Name = "cmbColoMaxUnits";
            this.cmbColoMaxUnits.Size = new System.Drawing.Size(279, 21);
            this.cmbColoMaxUnits.TabIndex = 10;
            // 
            // cmbColoName3
            // 
            this.cmbColoName3.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.cmbColoName3.FormattingEnabled = true;
            this.cmbColoName3.Location = new System.Drawing.Point(138, 65);
            this.cmbColoName3.Name = "cmbColoName3";
            this.cmbColoName3.Size = new System.Drawing.Size(279, 21);
            this.cmbColoName3.TabIndex = 8;
            // 
            // lblExcelColumns3
            // 
            this.lblExcelColumns3.AutoSize = true;
            this.lblExcelColumns3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.lblExcelColumns3.Location = new System.Drawing.Point(213, 27);
            this.lblExcelColumns3.Name = "lblExcelColumns3";
            this.lblExcelColumns3.Size = new System.Drawing.Size(0, 13);
            this.lblExcelColumns3.TabIndex = 11;
            // 
            // lblColoMaxUnits
            // 
            this.lblColoMaxUnits.AutoSize = true;
            this.lblColoMaxUnits.Location = new System.Drawing.Point(24, 114);
            this.lblColoMaxUnits.Name = "lblColoMaxUnits";
            this.lblColoMaxUnits.Size = new System.Drawing.Size(0, 13);
            this.lblColoMaxUnits.TabIndex = 9;
            // 
            // lblColoName3
            // 
            this.lblColoName3.AutoSize = true;
            this.lblColoName3.Location = new System.Drawing.Point(24, 65);
            this.lblColoName3.Name = "lblColoName3";
            this.lblColoName3.Size = new System.Drawing.Size(0, 13);
            this.lblColoName3.TabIndex = 7;
            // 
            // lblShapeField3
            // 
            this.lblShapeField3.AutoSize = true;
            this.lblShapeField3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.lblShapeField3.Location = new System.Drawing.Point(24, 27);
            this.lblShapeField3.Name = "lblShapeField3";
            this.lblShapeField3.Size = new System.Drawing.Size(0, 13);
            this.lblShapeField3.TabIndex = 6;
            // 
            // titleLabel
            // 
            this.titleLabel.AutoSize = true;
            this.titleLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.titleLabel.Location = new System.Drawing.Point(12, 9);
            this.titleLabel.Name = "titleLabel";
            this.titleLabel.Size = new System.Drawing.Size(0, 13);
            this.titleLabel.TabIndex = 0;
            // 
            // FrmSelectColumns
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.Controls.Add(this.tbCtrlSheetColumns);
            this.Name = "FrmSelectColumns";
            this.Load += new System.EventHandler(this.frmSelectColumns_Load);
            this.Controls.SetChildIndex(this.tbCtrlSheetColumns, 0);
            ((System.ComponentModel.ISupportInitialize)(this.pictureBoxIcon)).EndInit();
            this.tbCtrlSheetColumns.ResumeLayout(false);
            this.tbPageServer.ResumeLayout(false);
            this.gbServerPage.ResumeLayout(false);
            this.gbServerPage.PerformLayout();
            this.tbPageRack.ResumeLayout(false);
            this.gbRackPage.ResumeLayout(false);
            this.gbRackPage.PerformLayout();
            this.tbPageColo.ResumeLayout(false);
            this.gbColoPage.ResumeLayout(false);
            this.gbColoPage.PerformLayout();
            this.ResumeLayout(false);

        }

        #endregion

        #region Methods
        /// <summary>
        /// On Form Load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmSelectColumns_Load(object sender, EventArgs e)
        {
            try
            {
                // Header panel office icon
                System.IO.Stream xsdResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("RackServerManager.Images.office.ico");
                base.pictureBoxIcon.Image = System.Drawing.Image.FromStream(xsdResourceStream);              
            }
            catch (RackException ex)
            {

                // To catch and display exceptions from sub functions
                RackException.HandleExceptions(Global.GetResourceString("Exception_MsgBox_Caption"),
                            Global.GetResourceString("Exception_UsrMsg"), ex.InnerException);
            }
            catch (Exception ex)
            {
                // To catch exceptions from current functions
                RackException.HandleExceptions(Global.GetResourceString("Exception_MsgBox_Caption"),
                            Global.GetResourceString("Exception_UsrMsg"), ex);
            }            
        }

        /// <summary>
        /// Loads server sheet column names into combobox
        /// </summary>
        internal void LoadServerColumnNames()
        {
             try
            {
                // Clear server column comboboxes
                this.cmbNetworkName.Items.Clear();
                this.cmbPowerRating1.Items.Clear();
                this.cmbSpaceUsed.Items.Clear();
                this.cmbRackName1.Items.Clear();
                this.cmbColoName1.Items.Clear();
           
                // Add default string
                this.cmbNetworkName.Items.Add(Global.GetResourceString("FormSelectDefaultCombo_Text"));
                this.cmbPowerRating1.Items.Add(Global.GetResourceString("FormSelectDefaultCombo_Text"));
                this.cmbSpaceUsed.Items.Add(Global.GetResourceString("FormSelectDefaultCombo_Text"));
                this.cmbRackName1.Items.Add(Global.GetResourceString("FormSelectDefaultCombo_Text"));
                this.cmbColoName1.Items.Add(Global.GetResourceString("FormSelectDefaultCombo_Text"));

                // Loop through each server column & add into respective comboboxes
                foreach (string serverColumn in Global.ExcelServerColumnNames)
                {
                    this.cmbNetworkName.Items.Add(serverColumn);
                    this.cmbPowerRating1.Items.Add(serverColumn);
                    this.cmbSpaceUsed.Items.Add(serverColumn);
                    this.cmbRackName1.Items.Add(serverColumn);
                    this.cmbColoName1.Items.Add(serverColumn);
                }

                // Set index of column comboboxes. If column name is same as shape
                // field then select that particular column name else select default text
                if (!cmbNetworkName.Items.Contains(Global.ServerFieldNetworkName))
                {
                    cmbNetworkName.SelectedIndex = cmbNetworkName.Items.IndexOf(Global.GetResourceString("FormSelectDefaultCombo_Text"));
                }
                else
                {
                    cmbNetworkName.SelectedIndex = cmbNetworkName.Items.IndexOf(Global.ServerFieldNetworkName);
                }

                if (!cmbPowerRating1.Items.Contains(Global.ServerFieldPowerRating))
                {
                    cmbPowerRating1.SelectedIndex = cmbPowerRating1.Items.IndexOf(Global.GetResourceString("FormSelectDefaultCombo_Text"));
                }
                else
                {
                    cmbPowerRating1.SelectedIndex = cmbPowerRating1.Items.IndexOf(Global.ServerFieldPowerRating);
                }

                if (!cmbSpaceUsed.Items.Contains(Global.ServerFieldRackSpace))
                {
                    cmbSpaceUsed.SelectedIndex = cmbSpaceUsed.Items.IndexOf(Global.GetResourceString("FormSelectDefaultCombo_Text"));
                }
                else
                {
                    cmbSpaceUsed.SelectedIndex = cmbSpaceUsed.Items.IndexOf(Global.ServerFieldRackSpace);
                }

                 if (!cmbRackName1.Items.Contains(Global.ServerFieldRackName))
                {
                    cmbRackName1.SelectedIndex = cmbRackName1.Items.IndexOf(Global.GetResourceString("FormSelectDefaultCombo_Text"));
                }
                else
                {
                    cmbRackName1.SelectedIndex = cmbRackName1.Items.IndexOf(Global.ServerFieldRackName);
                }
                
                 if (!cmbColoName1.Items.Contains(Global.ServerFieldColoName))
                {
                    cmbColoName1.SelectedIndex = cmbColoName1.Items.IndexOf(Global.GetResourceString("FormSelectDefaultCombo_Text"));
                }
                else
                {
                    cmbColoName1.SelectedIndex = cmbColoName1.Items.IndexOf(Global.ServerFieldColoName);
                }

            }
            catch (RackException ex)
            {
                // Exception from sub function. Pass on to entry point
                throw new RackException("Load Server Column Names", ex.InnerException);

            }
            catch (Exception ex)
            {
                // Exception from sub function. Pass on to entry point
                throw new RackException("Load Server Column Names", ex.InnerException);

            }
        }

        /// <summary>
        /// Loads rack sheet column names into combobox
        /// </summary>
        internal void LoadRackColumnNames()
        {
            try
            {
                // Clear rack column comboboxes
                this.cmbRackName2.Items.Clear();
                this.cmbPowerRating2.Items.Clear();
                this.cmbMaxUnits.Items.Clear();
                this.cmbColoName2.Items.Clear();

                // Add default string
                this.cmbRackName2.Items.Add(Global.GetResourceString("FormSelectDefaultCombo_Text"));
                this.cmbPowerRating2.Items.Add(Global.GetResourceString("FormSelectDefaultCombo_Text"));
                this.cmbMaxUnits.Items.Add(Global.GetResourceString("FormSelectDefaultCombo_Text"));
                this.cmbColoName2.Items.Add(Global.GetResourceString("FormSelectDefaultCombo_Text"));

                // Loop through each rack column & add into respective comboboxes
                foreach (string rackColumn in Global.ExcelRackColumnNames)
                {
                    this.cmbRackName2.Items.Add(rackColumn);
                    this.cmbPowerRating2.Items.Add(rackColumn);
                    this.cmbMaxUnits.Items.Add(rackColumn);
                    this.cmbColoName2.Items.Add(rackColumn);
                }

                // Set index of column comboboxes. If column name is same as shape
                // field then select that particular column name else select default text              
                if (!cmbRackName2.Items.Contains(Global.RackFieldRackName))
                {
                    cmbRackName2.SelectedIndex = cmbRackName2.Items.IndexOf(Global.GetResourceString("FormSelectDefaultCombo_Text"));
                }
                else
                {
                    cmbRackName2.SelectedIndex = cmbRackName2.Items.IndexOf(Global.RackFieldRackName);
                }

                if (!cmbPowerRating2.Items.Contains(Global.RackFieldPowerRating))
                {
                    cmbPowerRating2.SelectedIndex = cmbPowerRating2.Items.IndexOf(Global.GetResourceString("FormSelectDefaultCombo_Text"));
                }
                else
                {
                    cmbPowerRating2.SelectedIndex = cmbPowerRating2.Items.IndexOf(Global.RackFieldPowerRating);
                }

                if (!cmbMaxUnits.Items.Contains(Global.RackFieldMaxUnits))
                {
                    cmbMaxUnits.SelectedIndex = cmbMaxUnits.Items.IndexOf(Global.GetResourceString("FormSelectDefaultCombo_Text"));
                }
                else
                {
                    cmbMaxUnits.SelectedIndex = cmbMaxUnits.Items.IndexOf(Global.RackFieldMaxUnits);
                }

                if (!cmbColoName2.Items.Contains(Global.RackFieldColoName))
                {
                    cmbColoName2.SelectedIndex = cmbColoName2.Items.IndexOf(Global.GetResourceString("FormSelectDefaultCombo_Text"));
                }
                else
                {
                    cmbColoName2.SelectedIndex = cmbColoName2.Items.IndexOf(Global.RackFieldColoName);
                }
            }
            catch (RackException ex)
            {
                // Exception from sub function. Pass on to entry point
                throw new RackException("Load Rack Column Names", ex.InnerException);
                
            }
            catch (Exception ex)
            {
                // Exception from sub function. Pass on to entry point
                throw new RackException("Load Rack Column Names", ex.InnerException);
                
            }
        }

        /// <summary>
        /// Loads colo sheet column names into combobox
        /// </summary>
        internal void LoadColoColumnNames()
        {
            try
            {
                // Clear colo column comboboxes
                this.cmbColoName3.Items.Clear();
                this.cmbColoMaxUnits.Items.Clear();

                // Add default string
                this.cmbColoName3.Items.Add(Global.GetResourceString("FormSelectDefaultCombo_Text"));
                this.cmbColoMaxUnits.Items.Add(Global.GetResourceString("FormSelectDefaultCombo_Text"));

                // Loop through each colo column & add into respective comboboxes
                foreach (string coloColumn in Global.ExcelColoColumnNames)
                {
                    this.cmbColoName3.Items.Add(coloColumn);
                    this.cmbColoMaxUnits.Items.Add(coloColumn);                    
                }

                // Set index of column comboboxes. If column name is same as shape
                // field then select that particular column name else select default text                              
                if (!cmbColoName3.Items.Contains(Global.ColoFieldColoName))
                {
                    cmbColoName3.SelectedIndex = cmbColoName3.Items.IndexOf(Global.GetResourceString("FormSelectDefaultCombo_Text"));
                }
                else
                {
                    cmbColoName3.SelectedIndex = cmbColoName3.Items.IndexOf(Global.ColoFieldColoName);
                }
                
                if (!cmbColoMaxUnits.Items.Contains(Global.ColoFieldMaxUnits))
                {
                    cmbColoMaxUnits.SelectedIndex = cmbColoMaxUnits.Items.IndexOf(Global.GetResourceString("FormSelectDefaultCombo_Text"));
                }
                else
                {
                    cmbColoMaxUnits.SelectedIndex = cmbColoMaxUnits.Items.IndexOf(Global.ColoFieldMaxUnits);
                }

            }
            catch (RackException ex)
            {
                // Exception from sub function. Pass on to entry point
                throw new RackException("Load Colo Column Names", ex.InnerException);

            }
            catch (Exception ex)
            {
                // Exception from sub function. Pass on to entry point
                throw new RackException("Load Colo Column Names", ex.InnerException);

            }
        }
        #endregion Methods    
    }
}
